/**
 * https://leetcode.cn/problems/increasing-order-search-tree/
 */
function increasingBST(root: TreeNode | null): TreeNode | null {
    const newRoot = new TreeNode()
    let tempNode = newRoot

    const inOrder = (node: TreeNode | null) => {
        if (node === null) return null
        inOrder(node.left)
        tempNode = tempNode.right = node
        node.left = null
        inOrder(node.right)
    }
    inOrder(root)

    return newRoot.right
};